package com.mtauto.action.apk;

import java.util.Collection;

import org.codeanywhere.easyRestful.base.RequestContext;
import org.codeanywhere.easyRestful.base.annotation.Request;
import org.codeanywhere.easyRestful.base.annotation.SpringBean;

import com.mtauto.model.Apk;
import com.mtauto.service.ApkService;

public class Gen {
    @SpringBean
    private ApkService     apkService;
    @Request
    private RequestContext rc;

    public void execute() {

    }

    public void genApk() {
        String p2 = rc.getHttpServletRequest().getParameter("activityClass");
        Collection<Apk> apks = apkService.getApks();
        String p1 = "";
        for (Apk apk : apks) {
            if (!apk.getTitle().equals("cafeTest")) {
                p1 = apk.getName();
                break;
            }
        }
        ApkService.targetPackage = p1;
        try {
            apkService.genRecordApk(p1, p2);
            rc.put("code", 200);
        } catch (Exception e) {
            e.printStackTrace();
            rc.put("code", 301);
            rc.put("msg", e.getMessage());
        }
    }

}
